<?php

use Controller\Mobile;
use Logic\Store\StoreLogic;
use Core\Exception;

/**
 * 店铺中心
 * Class StoreController
 */
class StoreController extends Mobile
{

    protected $needLoginActions = ['addFollow', 'uploadLogo', 'storeContract', 'followStore'];

    public function init()
    {
        parent::init();
    }

    /**
     * 商铺列表
     */
    public function indexAction()
    {
        $this->view(['title' => '商铺列表']);
    }

    /**
     * 商家信息（店铺中心）
     * @throws Exception
     */
    public function storeCenterAction()
    {
        $id     = $this->request->get('id', '');
        $userId = isset($this->userInfo['id']) ? $this->userInfo['id'] : ''; //如果未登陆的话，userId可以为空

        $dataOne = (new StoreLogic())->getStoreDetail(['storeId' => $id],$userId);

        $this->view(['title' => '商家信息', 'dataOne' => $dataOne]);
    }

    //更新店铺信息
    public function updateStoreAction(){
        (new StoreLogic())->updateStroe($this->request->post('','',false),$this->userInfo);
        $this->json(1, '数据更新成功');
    }
}